import { create } from 'zustand';

type ChatStore = {
  searchQuestion: string;
  isDeepMode: boolean;
  isOnlineMode: boolean;
  actions: {
    setSearchQuestion: (q: string) => void;
    setIsDeepMode: (q: boolean) => void;
    setIsOnlineMode: (q: boolean) => void;
  };
};

const useChatStore = create<ChatStore>((set) => ({
  searchQuestion: '',
  isDeepMode: false,
  isOnlineMode: false,
  actions: {
    setSearchQuestion: (params) => {
      set({ searchQuestion: params });
    },
    setIsDeepMode: (params) => {
      set({ isDeepMode: params });
    },
    setIsOnlineMode: (params) => {
      set({ isOnlineMode: params });
    },
  },
}));

export const useChatActions = () => useChatStore((state) => state.actions);
export const useSearchQuestion = () => useChatStore((state) => state.searchQuestion);
export const useIsDeepMode = () => useChatStore((state) => state.isDeepMode);
export const useIsOnlineMode = () => useChatStore((state) => state.isOnlineMode);
export default useChatStore;